package de.tum.in.eist.poll.client.views;

import java.util.ArrayList;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.VerticalPanel;

import de.tum.in.eist.poll.client.views.widgets.QuestionWidget;
import de.tum.in.eist.poll.shared.beans.Question;

/**
 * 
 * @author Sebastian Hofstetter
 *
 */
public class PollView extends View{
	private VerticalPanel pollPanel = new VerticalPanel();
	
	private Button submitButton = new Button("Submit");
	
	private DialogBox dialogBox = new DialogBox(true);
	
	private ArrayList<QuestionWidget> questionWidgets = new ArrayList<QuestionWidget>();
	
	public PollView(Question[] questions) {
		
		dialogBox.setText("Successfully submitted feedback!");
		dialogBox.setAnimationEnabled(true);
		dialogBox.setGlassEnabled(true);
		dialogBox.add(new Image("images/thumbsup.jpg"));
		
		for (Question q : questions) {
			QuestionWidget w = q.getWidget();
			questionWidgets.add(w);
			pollPanel.add(w);
		}
		
		submitButton.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				dialogBox.center();
			}
		});
		pollPanel.add(submitButton);
		
		
		initWidget(pollPanel);
		pollPanel.addStyleName("pollView");
	}
}
